import { Toast } from "vant";

export const myMixins = {
  data () {
    return {
      fontSize:localStorage.getItem('fontSize') || 1
    }
  },
  methods: {
    toView(path){
      this.$router.push(path)
    },
	addZanBtn(item) {
	  console.log('addZanBtn',item)
	  this.$request.newsAddZan({id:item.id}).then(res=>{
		  
	  })
	},
	toDetailView(item) {
		if (this.partyItem) {
			this.bus.$emit('refreshPartDetail', item)
		}
		console.log('item.jump_url', item.jump_url);
		if(item.jump_url){
			window.location.href = item.jump_url;
			// window.open(item.jump_url);
			// self.location = item.jump_url
		}else{
			this.$router.push(`/common/detail/${item.id}?img_url=${item.main_img}`);
		}
	},
    shareInit(href,detail) {
		console.log('shareInit',href)
    	const _this = this;
    	const url = (href.split('#')[0])
    	let params = {
    		url: url
    	}
    	_this.$request.getWeixinConfig(params).then(res => {
			console.log('getWeixinConfig__res',res)
    		if (res.code == 200) {
    			wx.config({
    				debug: false, // 是否开启调试模式
    				appId: res.data.appId, //appid
    				timestamp: res.data.timestamp, // 时间戳
    				nonceStr: res.data.nonceStr, // 随机字符串
    				signature: res.data.signature, // 签名
    				jsApiList: ['checkJsApi', 'updateAppMessageShareData', 'updateTimelineShareData'] // 需要使用的JS接口列表
    			})
				console.log('detail',detail)
    			const dataShare = {
    				title: detail.title,
    				desc: detail.policy_keywords, // 分享描述
    				link: url, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
    				imgUrl: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-767674fd-0f0e-4801-90e6-bef27c2e36df/24fbe596-f7d0-43e4-84a5-ad7428c842c1.png', // 分享图标
    				success: function () {
    				    // 设置成功
    					console.log('设置成功')
    				},
    				fail:function(error){
    					console.log('设置失败')
    				  //  alert(JSON.stringify(error))
    				}
    			}
    			wx.updateAppMessageShareData(dataShare)
    			wx.updateTimelineShareData(dataShare)
    			wx.error(function (error) {
    				// alert(JSON.stringify(error))
					console.log('设置失败',JSON.stringify(error))
    			})
    		} else {
    			Toast('configJssdk error')
    		}
    	})
    }
  }
}